cmake_minimum_required(VERSION 3.20)
set(PROJ_NAME case28)
project(${PROJ_NAME})

add_executable(${PROJ_NAME}
    main.cpp
    )

add_custom_command(OUTPUT $<IF:$<CONFIG:Debug>,${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt,dummy>
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:Debug>,copy_if_different,true> ${CMAKE_SOURCE_DIR}/src_Debug.txt ${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:Debug>,echo,true> "Copy src_Debug.txt to src_File.txt"
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<CONFIG:Debug>,true,touch> dummy
    DEPENDS $<$<CONFIG:Debug>:${CMAKE_SOURCE_DIR}/src_Debug.txt>
    )

add_custom_command(OUTPUT $<IF:$<NOT:$<CONFIG:Debug>>,${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt,dummy>
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<NOT:$<CONFIG:Debug>>,copy_if_different,true> ${CMAKE_SOURCE_DIR}/src_Release.txt ${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<NOT:$<CONFIG:Debug>>,echo,true> "Copy src_Release.txt to src_File.txt"
    COMMAND ${CMAKE_COMMAND} -E $<IF:$<NOT:$<CONFIG:Debug>>,true,touch> dummy
    DEPENDS $<$<NOT:$<CONFIG:Debug>>:${CMAKE_SOURCE_DIR}/src_Release.txt>
    )    

add_custom_target(DataFiles
    DEPENDS
    $<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt>
    $<$<NOT:$<CONFIG:Debug>>:${CMAKE_BINARY_DIR}/$<CONFIG>/src_File.txt>
    COMMENT "Build DataFiles target"
    )

add_dependencies(${PROJ_NAME} DataFiles)
